package cn.kgc.mybatis.mapper;

import cn.kgc.mybatis.entity.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 课工场
 * @date 2024/4/24
 * @description
 */
public interface DeptMapper {

    @Results(id = "deptMap", value = {
            @Result(column = "id", property = "id"),
            @Result(column = "local", property = "local"),
            @Result(column = "dept_name", property = "dName")
    })
    @Select("select * from dept")
    List<Dept> selectDepts();


    @Select("select * from dept where id = #{id}")
    @ResultMap("deptMap")
    Dept selectDept(Integer id);

    @Insert("insert into dept (dept_name,local)values (#{dName},#{local})")
    Integer addDept(Dept dept);

    @Update("update dept set local = #{local} where id = #{id}")
    Integer updateDept(Dept dept);

    @Delete("delete from dept where id = #{id}")
    Integer deleteDept(Integer id);
}
